//
//  ViewController.m
//  第二题
//
//  Created by dllo on 16/6/6.
//  Copyright © 2016年 zuzhiming. All rights reserved.
//

#import "ViewController.h"

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    UIImageView *backGroundImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"BackGround"]];
    
    [self.view addSubview:backGroundImageView];
    [backGroundImageView release];
    
    [self createFlowers];
    [self createZombieAnimation];
}


//小花
- (void)createFlowers
{
    UIImageView *flowersImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"flower1.tiff"]];
    flowersImageView.frame = CGRectMake(60, 100, 60, 60);
    [self.view addSubview:flowersImageView];
    [flowersImageView release];
    
    NSMutableArray *flowerArray = [NSMutableArray array];
    
    for (NSInteger i = 1; i <= 18; i++) {
        NSString *name = [NSString stringWithFormat:@"flower%ld.tiff", i];
        UIImage *flowerImage = [UIImage imageNamed:name];
        [flowerArray addObject:flowerImage];
    }
    flowersImageView.animationImages = flowerArray;
    
    flowersImageView.animationDuration = 0.5f;
    
    [flowersImageView startAnimating];
    
}

//僵尸
- (void)createZombieAnimation
{
    UIImageView *zombieImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"BZombie1.tiff"]];
    zombieImageView.frame = CGRectMake(280, 100, 100, 180);
    [self.view addSubview:zombieImageView];
    [zombieImageView release];
    
    NSMutableArray *zombieArray = [NSMutableArray array];
    
    for (NSInteger i = 1; i <= 25; i++) {
        NSString *name = [NSString stringWithFormat:@"BZombie%ld.tiff", i];
        UIImage *zombieImage = [UIImage imageNamed:name];
        [zombieArray addObject:zombieImage];
    }
    zombieImageView.animationImages = zombieArray;
    
    zombieImageView.animationDuration = 0.8f;
    
    [zombieImageView startAnimating];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
